//
//  MOFoodAppraiseCell.m
//  MobileOffice
//
//  Created by 晓 on 2019/10/15.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MOFoodAppraiseCell.h"

@interface MOFoodAppraiseCell ()

@property (nonatomic, strong) UIView *backView;

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *foodNameLabel;

@property (nonatomic, strong) UILabel *cookerNameLabel;

@end

@implementation MOFoodAppraiseCell

- (MOFoodAppraiseCell *)cellCreat:(NSString *)cellIdentifier AndArray:(NSMutableArray *)array andTableView:(UITableView *)tableView cellIndexPath:(NSIndexPath *)indexPath andType:(NSInteger)type{
    YPBaseSwipeTableViewCell *cell  = [self initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier withBtn:array tableView:tableView cellIndexPath:indexPath andType:type];
    self.YPContentView.backgroundColor = KGrayColor_f8f8f8;
    [cell creatUI];
    return self;
}

- (void)creatUI{
    [self.YPContentView addSubview:self.backView];
}

-(void)setModel:(MOFoodAppraiseModel *)model
{
    self.titleLabel.text = model.dishName;
    
    if ([model.isMy integerValue]==1) {
        
        self.foodNameLabel.text = model.createTime;
        
        self.cookerNameLabel.text = [NSString stringWithFormat:@"评价分数：%@分",model.star];
    }else{
        self.foodNameLabel.text = model.restaurantName;
        
        self.cookerNameLabel.text = [NSString stringWithFormat:@"厨师：%@",model.cook];
    }
    
}

#pragma mark -懒加载

- (UIView *)backView{
    if (!_backView) {
        _backView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH - 10*2, 80)];
        _backView.backgroundColor = KWhiteColor;
        
        [_backView addSubview:self.titleLabel];
        [_backView addSubview:self.foodNameLabel];
        [_backView addSubview:self.cookerNameLabel];
        
    }
    return _backView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(18, 16, (self.backView.width - 20)/2, 16)];
        _titleLabel.font = [UIFont boldSystemFontOfSize:16];
        _titleLabel.textColor = KBlackColor_2A2A2A;
        _titleLabel.text = @"手抓饭";
    }
    return _titleLabel;
}

- (UILabel *)foodNameLabel{
    if (!_foodNameLabel) {
        _foodNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.right, self.titleLabel.top, self.titleLabel.width - 18, self.titleLabel.height)];
        _foodNameLabel.font = FONT_SIZE(13);
        _foodNameLabel.textAlignment = NSTextAlignmentRight;
        _foodNameLabel.textColor = KBlackColor_2A2A2A;
        _foodNameLabel.text = @"第一餐厅";
    }
    return _foodNameLabel;
}

- (UILabel *)cookerNameLabel{
    if (!_cookerNameLabel) {
        _cookerNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.left, self.titleLabel.bottom + 19, self.backView.width, 13)];
        _cookerNameLabel.font = FONT_SIZE(13);
        _cookerNameLabel.textColor = KBlackColor_2A2A2A;
        _cookerNameLabel.text = @"厨师：张玉林";
    }
    return _cookerNameLabel;
}

@end
